﻿<cfcomponent 
	displayname="public.service.helper.tagCookie" 
	hint="CFCookie Tag Operation Helper" 
	output="false">
	
	<cffunction name="init" access="public" returntype="public.service.helper.tagCookie" hint="初始化对象">
		<cfreturn this />
	</cffunction>
	
	<cffunction name="create" access="public" returntype="void" hint="创建 Cookie ">
		<cfargument name="name" type="string" required="yes" hint="Cookie 变量名" />
		<cfargument name="domain" type="string" required="yes" hint="Cookie 作用域" />
		<cfargument name="path" type="string" required="yes" hint="Cookie 作用路径" />
		<cfargument name="secure" type="boolean" required="yes" hint="是否只在 Https 协议下发送" />
		<cfargument name="httponly" type="boolean" required="yes" hint="是否只可用于 HTTP 协议" />
		<cfargument name="value" type="string" required="yes" hint="Cookie 变量对应值" />
		<cfargument name="expires" type="string" required="no" default="" hint="Cookie 过期时间" />
		
		<cfif len(arguments.expires)>
			<cfcookie name="#arguments.name#" domain="#arguments.domain#" path="#arguments.path#" expires="#arguments.expires#" secure="#arguments.secure#" httponly="#arguments.httponly#" value="#arguments.value#" />
		<cfelse>
			<cfcookie name="#arguments.name#" domain="#arguments.domain#" path="#arguments.path#" secure="#arguments.secure#" httponly="#arguments.httponly#" value="#arguments.value#" />
		</cfif>
		
	</cffunction>
	
	<cffunction name="expires" access="public" returntype="void" hint="删除 Cookie">
		<cfargument name="name" type="string" required="yes" hint="Cookie 变量名" />
		<cfargument name="domain" type="string" required="yes" hint="Cookie 作用域" />
		<cfargument name="path" type="string" required="yes" hint="Cookie 作用路径" />
		
		<cfcookie name="#arguments.name#" domain="#arguments.domain#" path="#arguments.path#" expires="now" />
		
	</cffunction>
	
</cfcomponent>